import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.sql.SparkSession

object WithHive {
  private val warehouseLocation = "spark-warehouse"
  private val conf: SparkConf = new SparkConf()
    .setMaster("master[*]")
    .setAppName("spark-hive connection")
  private val spark:SparkSession = SparkSession.builder()
    .master("local[*]")
    .config("spark.sql.warehouse.dir", warehouseLocation)
    .appName("spark-hive connection")
    .enableHiveSupport()
    .getOrCreate()
  //private val sc: SparkContext = new SparkContext(conf)
  //private val hc: HiveContext = new HiveContext(sc)

  import spark.implicits._

  def main(args: Array[String]): Unit = {
    print("success!")
    show()
  }

  def show(): Unit = {
    val rdd = spark.sql("select * from sparktest.student").rdd
  }
}
